package com.company.factory;

public class SimpleFactory {
    static SimpleFactory simpleFactory = null;

    public static SimpleFactory getInstance() {
        if (simpleFactory == null) {
            synchronized (SimpleFactory.class) {
                if (simpleFactory == null) {
                    simpleFactory = new SimpleFactory();
                }
            }
        }
        return simpleFactory;
    }

    public Fruit getObject(String name) {
        if (name.equals("Apple")) {
            return new Apple();
        } else if (name.equals("Peer")) {
            return new Peer();
        } else {
            return null;
        }
    }


}
